home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / CU Amiga 13.adf / T / ed-backup
Text File  |  2000-08-15  |  7KB  |  213 lines

  1. **********************************************************************
  2. *                                                                    *
  3. *                LOADER ROUTINE FOR AMIGA ARMY MOVES                 *
  4. *                                                                    *
  5. ***********************************************************************
  6.  
  7.                 xref    screens,stack,game,download
  8.  
  9.                 include "equates"
  10.  
  11. start:          move.w  #$07f0,custom+dmacon    ;7f0
  12.                 lea     stack,a7                ;setup stack pointer
  13.                 lea     blacks,a1
  14.                 bsr     setcol
  15.  
  16.                 lea     normcop,a0
  17.                 lea     download,a1
  18.                 moveq   #9,d0
  19. sue:            move.l  (a0)+,(a1)+
  20.                 dbf     d0,sue
  21.  
  22. setupscr:       lea     custom,a0
  23.                 move.w  #$0000,bpl1mod(a0)      ;only 40 chars accross
  24.                 move.w  #$0000,bpl2mod(a0)      ;
  25.                 move.w  #$4200,bplcon0(a0)
  26.                 move.w  #$0000,bplcon1(a0)
  27.                 move.w  #$0064,bplcon2(a0)
  28.                 move.w  #$0038,ddfstrt(a0)
  29.                 move.w  #$00d0,ddfstop(a0)
  30.                 move.w  #$2c81,diwstrt(a0)
  31.                 move.w  #$f4c1,diwstop(a0)
  32.                 move.l  #download,cop1lch(a0)     ;standard copper
  33.                 move.w  custom+copjmp1,d0
  34.                 move.w  #$7fff,dmacon(a0)
  35.                 move.w  #$87df,dmacon(a0)
  36.                 bra     main
  37.  
  38. ;copper list
  39. ;-----------
  40. normcop:        dc.w    $00e0,screen1/$10000
  41.                 dc.w    $00e2,screen1&$ffff
  42.                 dc.w    $00e4,screen2/$10000
  43.                 dc.w    $00e6,screen2&$ffff
  44.                 dc.w    $00e8,screen3/$10000
  45.                 dc.w    $00ea,screen3&$ffff
  46.                 dc.w    $00ec,screen4/$10000
  47.                 dc.w    $00ee,screen4&$ffff
  48.                 dc.w    $ffff,$fffe
  49.  
  50. ;routine to setup colours to those pointed at by a1
  51. ;--------------------------------------------------
  52. setcol:         lea     custom+color00,a0
  53.                 moveq   #15,d0
  54. oncol:          move.w  (a1)+,(a0)+
  55.                 dbf     d0,oncol
  56.                 rts
  57.  
  58. chicken:        lea     custom+color00,a0
  59.                 move.w  (a0),d0
  60.                 addi.w  #$01,d0
  61.                 andi.w  #$fff,d0
  62.                 move.w  d0,(a0)
  63.                 bra     chicken
  64.  
  65. blacks:         ds.w    16
  66.  
  67. titcols:        dc.w    $000,$200,$310,$410,$421,$776,$760,$730
  68.                 dc.w    $432,$321,$112,$223,$334,$445,$557,$500
  69.  
  70. ;main routine to handle loader
  71. ;-----------------------------
  72. main:           bsr     lob_screen_up
  73.                 lea     titcols,a1
  74.                 bsr     setcol
  75.                 bsr     load_it_in
  76.                 move.w  #$4000,custom+intena
  77.                 bsr     relocater
  78.                 bra     set_download
  79.  
  80. ;routine to lob degas picture to amiga four colour screen
  81. ;--------------------------------------------------------
  82. lob_screen_up:  lea     screen1,a1
  83.                 lea     screen2,a2
  84.                 lea     screen3,a3
  85.                 lea     screen4,a4
  86.                 lea     top,a0
  87.  
  88.                 move.l  #3999,d7
  89. agro_loop:      move.w  (a0)+,(a1)+
  90.                 move.w  (a0)+,(a2)+
  91.                 move.w  (a0)+,(a3)+
  92.                 move.w  (a0)+,(a4)+
  93.                 dbf     d7,agro_loop
  94.                 rts
  95.  
  96. *************************************************************************
  97. *                                                                       *
  98. *                       loader program                                  *
  99. *                                                                       *
  100. *************************************************************************
  101.  
  102. ;macro's
  103. ;-------
  104.  
  105. calexec:        MACRO
  106.                 move.l  Sysbase,a6
  107.                 jsr     \1(a6)
  108.                 ENDM
  109.  
  110. calldos:        MACRO
  111.                 move.l  DOSbase,a6
  112.                 jsr     \1(a6)
  113.                 ENDM
  114.  
  115. load_it_in:     lea     dosn,a1
  116.                 moveq   #0,d0
  117.                 calexec OpenLibrary
  118.                 move.l  d0,DOSbase
  119.  
  120.                 move.l  #mode_oldfile,d2
  121.                 move.l  #fname,d1
  122.                 calldos Open
  123.                 move.l  d0,filehandle
  124.                 tst.l   d0
  125.                 beq     error
  126.  
  127.                 move.l  d0,d1
  128.                 move.l  #game,d2
  129.                 move.l  #$6ffff,d3
  130.                 calldos Read
  131.                 tst.l   d0
  132.                 bmi     error
  133.  
  134.                 move.l  filehandle,d1
  135.                 calldos Close
  136.                 rts
  137.  
  138. error:          move.w  #$0fff,$dff180
  139.                 bra     error
  140.  
  141. ;----------------------------------------------------------------------
  142. ;               marcs amazing relocation routine
  143. ;----------------------------------------------------------------------
  144. hunk2_start:    equ     $3dc00          ;this is where the bss will sit
  145. hunk1_start:    equ     $2000           ;this is where the program will sit
  146. old_code:       equ     game+$24        ;where code now sits
  147. hunk_info:      equ     game+$3bb7c     ;relocation information
  148.  
  149. relocater:      lea     hunk_info+4,a2  ;where the first addresses start
  150.                 move.l  #hunk1_start,d0 ;start object address of hunk 1
  151.                 lea     old_code,a1
  152.                 move.l  (a2)+,d7
  153.                 adda.l  #4,a2           ;skip over hunk number
  154.                 subi.l  #$01,d7
  155.                 bsr     relocate_hunk   ;relocates to be done
  156.                 move.l  (a2)+,d7        ;do next hunk
  157.                 subi.l  #$01,d7
  158.                 adda.l  #4,a2
  159.                 move.l  #hunk2_start,d0 ;start object address of hunk 2
  160.                 bsr     relocate_hunk
  161.                 rts
  162.  
  163. relocate_hunk:  move.l  (a2)+,d1        ;get relocate offset
  164.                 move.l  a1,a3
  165.                 adda.l  d1,a3           ;points a3 to long to modify
  166.                 add.l   d0,(a3)         ;adds hunk base address
  167.                 dbf     d7,relocate_hunk
  168.                 rts
  169.  
  170. ;routine that has to be sent to 'download' buffer
  171. ;------------------------------------------------
  172. set_download:   lea     downloader,a0
  173.                 lea     $7ff00,a1
  174.                 moveq   #99,d7
  175. sdownlp:        move.w  (a0)+,(a1)+
  176.                 dbf     d7,sdownlp
  177.                 jmp     $7ff00
  178.  
  179. downloader:     lea     hunk1_start,a0
  180.                 lea     old_code,a1
  181.                 move.l  #$eed8,d0
  182. trx_loop:       move.l  (a1)+,(a0)+
  183.                 subi.l  #$01,d0
  184.                 bne     trx_loop
  185.                 jmp     hunk1_start
  186.  
  187. ;information for system calls
  188. ;-----------------------------
  189. Sysbase:        equ     4
  190. OpenLibrary:    equ     -552
  191. Close:          equ     -36
  192. Read:           equ     -42
  193. Open:           equ     -30
  194. mode_oldfile:   equ     1005
  195.  
  196. filehandle:     dc.l    0
  197. DOSbase:        dc.l    0
  198.  
  199. fname:          dc.b    'df0:out',0
  200. dosn:           dc.b    'dos.library',0
  201.  
  202. screen1:        equ     $78200
  203. screen2:        equ     $7a140
  204. screen3:        equ     $7c080
  205. screen4:        equ     $7dfc0
  206.  
  207.                 include 'pic1.mac'
  208.                 include 'pic2.mac'
  209.  
  210.                 END
  211.  
  212.  
  213.